<?php
declare (strict_types = 1);

namespace app\product\model;

/**
 * @mixin \think\Model
 */
class SupplierModel extends BaseModel
{
    protected $table = 'tb_product_suppliers';
    protected $append = ['province_name','city_name','area_name'];

    const WITH_PROVINCE = 'province';
    public function province(){
        return $this->hasOne('app\product\model\RegionProvinceModel', 'province_code','province_code')->bind(['province_name'=>'name']);
    }

    const WITH_CITY = 'city';
    public function city(){
        return $this->hasOne('app\product\model\RegionCityModel', 'city_code','city_code')->bind(['city_name'=>'name']);
    }

    const WITH_AREA = 'area';
    public function area(){
        return $this->hasOne('app\product\model\RegionAreaModel', 'area_code','area_code')->bind(['area_name'=>'name']);
    }
}
